package com.heima.stroke.handler.valuation;

//每公里收钱
public class BasicValuation implements Valuation {
    private Valuation valuation;

    private float basicPrice=2.3F;

    public BasicValuation(Valuation valuation){
        this.valuation = valuation;
    }

    @Override
    //计费规则：3公里以内起步价13元；3公里以上2.3元/公里；燃油附加费1次收取1元
    public float calculation(float km) {
        float beforeCost=(valuation==null?0f: valuation.calculation(km));
        if (km < 3) {
            return beforeCost;
        }
        return beforeCost+(km-3)*basicPrice;
    }
}
